//
//  MeetingTableViewCell.m
//  Gxj
//
//  Created by 💋索少杰 on 2017/9/14.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "MeetingTableViewCell.h"
#import <SDAutoLayout.h>

@implementation MeetingTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        //添加到视图
        //用户点击头像响应
        //头像背景
        [self.contentView addSubview:self.viewIconCenterHY];
        [self.viewIconCenterHY addSubview:self.iconTouxiangCenterHY];
        //用户名字显示
        [self.contentView addSubview:self.nameTextCenterHY];
        //用户等级图标
        [self.contentView addSubview:self.dengjiTBCenterHY];
        //用户等级显示
        [self.contentView addSubview:self.dengjiTextCenterHY];
        //浏览人数图标
        [self.contentView addSubview:self.iconLiulangCenterHY];
        //观看人数
        [self.contentView addSubview:self.liulangNumCenterHY];
        //发表时间图标
        [self.contentView addSubview:self.iconShijianCenterHY];
        //用户发表时间
        [self.contentView addSubview:self.shijianTextCenterHY];
        //点赞数量
        [self.contentView addSubview:self.dianzanNumCenterHY];
        //点赞图片
        [self.contentView addSubview:self.dianzanIconCenterHY];
        //简介阴影
        [self.contentView addSubview:self.jianJieViewCenterHY];
        //简介内容
        [self.jianJieViewCenterHY addSubview:self.jianjieContextCenterHY];
        //用户发表图片
        [self.contentView addSubview:self.fabiaoImageCenterHY];
        //关注按钮
        [self.contentView addSubview:self.guanzhuCenterHY];
        //最佳讨论文字
        [self.contentView addSubview:self.zuijiaTextCenterHY];
        //最佳用户头像
        //        [self addSubview:self.iconZuijia];
        //线条
        [self.contentView addSubview:self.labelLine];
        
        //添加最佳用户头像
        //[self.iconZuijiaCenterBL addSubview:self.addButCenterBL];
        //进入会议
        [self.contentView addSubview:self.enterInto];
        //用户发表内容
        [self.fabiaoImageCenterHY addSubview:self.thelabelHY];
        
        //商业标签
        for (int i = 0; i < 3; i++) {
            _theLabelCenterHY = [[UILabel alloc] initWithFrame:CGRectMake(kWidthScale(5) + kWidthScale(40) * i, kHeightScale(5), kWidthScale(35), kHeightScale(15))];
            
            _theLabelCenterHY.backgroundColor = [UIColor colorWithWhite:0 alpha:0.1];
            _theLabelCenterHY.text = @"商业";
            _theLabelCenterHY.textColor = [UIColor colorWithWhite:0.9 alpha:1];
            _theLabelCenterHY.font = [UIFont systemFontOfSize:kWidthScale(9)];
            _theLabelCenterHY.textAlignment = NSTextAlignmentCenter;
            _theLabelCenterHY.layer.cornerRadius = kWidthScale(5);
            _theLabelCenterHY.layer.masksToBounds = YES;
            
            [self.fabiaoImageCenterHY addSubview:self.theLabelCenterHY];
        }
        //最佳用户头像
        for (int i = 0; i < 5; i++) {
            _iconZuijia = [[UIImageView alloc] initWithFrame:CGRectMake(kWidthScale(84) * (i+1) - (66*i), kHeightScale(243), kWidthScale(20), kHeightScale(20))];
            
            _iconZuijia.image=[UIImage imageNamed:@"toixiang"];
            [self.contentView addSubview:_iconZuijia];
            
        }
        //适配方法
        [self setUpadapter];

    }
    return self;
}
//适配方法
- (void)setUpadapter
{
    //头像背景
    _viewIconCenterHY.sd_layout
    .topSpaceToView(self.contentView, kHeightScale(11))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .widthIs(kWidthScale(25))
    .heightIs(kHeightScale(25));
    
    //头像
    _iconTouxiangCenterHY.sd_layout
    .topSpaceToView(self.viewIconCenterHY, kHeightScale(1.5))
    .leftSpaceToView(self.viewIconCenterHY, kWidthScale(1.5))
    .widthIs(kWidthScale(22))
    .heightIs(kHeightScale(22));
    
    //名字
    _nameTextCenterHY.sd_layout
    .topSpaceToView(self.contentView, kHeightScale(10))
    .leftSpaceToView(self.viewIconCenterHY, kWidthScale(5))
    .widthIs(kWidthScale(100))
    .autoHeightRatio(0);
    
    //等级图标
    _dengjiTBCenterHY.sd_layout
    .topSpaceToView(self.nameTextCenterHY, kHeightScale(2))
    .leftSpaceToView(self.viewIconCenterHY, kWidthScale(5))
    .widthIs(kWidthScale(11))
    .heightIs(kHeightScale(11));
    //等级时间
    _dengjiTextCenterHY.sd_layout
    .topSpaceToView(self.nameTextCenterHY, kHeightScale(2))
    .leftSpaceToView(self.dengjiTBCenterHY, kWidthScale(2))
    .widthIs(kWidthScale(40))
    .autoHeightRatio(0);
   
    
    //时间图标
    _iconShijianCenterHY.sd_layout
    .topSpaceToView(self.dengjiTextCenterHY, kHeightScale(5))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .widthIs(kWidthScale(15))
    .heightIs(kHeightScale(15));
    //时间
    _shijianTextCenterHY.sd_layout
    .topSpaceToView(self.dengjiTextCenterHY, kHeightScale(5))
    .leftSpaceToView(self.iconShijianCenterHY, kWidthScale(5))
    .widthIs(kWidthScale(30))
    .autoHeightRatio(0);
    //浏览图标
    _iconLiulangCenterHY.sd_layout
    .topSpaceToView(self.dengjiTextCenterHY, kHeightScale(7.5))
    .leftSpaceToView(self.shijianTextCenterHY, kWidthScale(5))
    .widthIs(kWidthScale(15))
    .heightIs(kHeightScale(10));
    //浏览人数
    _liulangNumCenterHY.sd_layout
    .topSpaceToView(self.dengjiTextCenterHY, kHeightScale(5))
    .leftSpaceToView(self.iconLiulangCenterHY, kWidthScale(5))
    .widthIs(kWidthScale(30))
    .autoHeightRatio(0);
    //点赞图片
    _dianzanIconCenterHY.sd_layout
    .topSpaceToView(self.dengjiTextCenterHY, kHeightScale(5))
    .leftSpaceToView(self.liulangNumCenterHY, kWidthScale(10))
    .widthIs(kWidthScale(13))
    .heightIs(kHeightScale(13));
    //点赞数量
    _dianzanNumCenterHY.sd_layout
    .topSpaceToView(self.dengjiTextCenterHY, kHeightScale(5))
    .leftSpaceToView(self.dianzanIconCenterHY, kWidthScale(5))
    .widthIs(kWidthScale(45))
    .autoHeightRatio(0);
    //发表图片
    _fabiaoImageCenterHY.sd_layout
    .topSpaceToView(self.shijianTextCenterHY, kHeightScale(10))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .rightSpaceToView(self.contentView, kWidthScale(15))
    .heightIs(kHeightScale(110));
    //简介View阴影
    _jianJieViewCenterHY.sd_layout
    .topSpaceToView(self.fabiaoImageCenterHY, kHeightScale(5))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .rightSpaceToView(self.contentView, kWidthScale(15))
    .heightIs(kHeightScale(49));
    //简介
    _jianjieContextCenterHY.sd_layout
    .topSpaceToView(self.jianJieViewCenterHY, 0)
    .leftSpaceToView(self.jianJieViewCenterHY, 0)
    .rightSpaceToView(self.jianJieViewCenterHY, 0)
    .heightIs(kHeightScale(49));

    //最佳文字
    _zuijiaTextCenterHY.sd_layout
    .topSpaceToView(self.jianJieViewCenterHY, kHeightScale(15))
    .leftSpaceToView(self.contentView, kWidthScale(15))
    .widthIs(kWidthScale(60))
    .autoHeightRatio(0);
    //线条
    _labelLine.sd_layout
    .bottomSpaceToView(self.contentView, 0)
    .leftSpaceToView(self.contentView, 0)
    .rightSpaceToView(self.contentView, 0)
    .heightIs(kHeightScale(1));
    //进入会议
    _enterInto.sd_layout
    .topSpaceToView(self.jianJieViewCenterHY, kHeightScale(11))
    .rightSpaceToView(self.contentView, kWidthScale(15))
    .widthIs(kWidthScale(112/2))
    .heightIs(kHeightScale(40/2));
    //用户发布内容
    _thelabelHY.sd_layout
    .bottomSpaceToView(self.fabiaoImageCenterHY, 0)
    .leftSpaceToView(self.fabiaoImageCenterHY, 0)
    .rightSpaceToView(self.fabiaoImageCenterHY, 0)
    .heightIs(kHeightScale(40/2));
}
//头像背景
- (UIView *)viewIconCenterHY
{
    if (!_viewIconCenterHY)
    {
        _viewIconCenterHY=[[UIView alloc] init];
        _viewIconCenterHY.backgroundColor = [UIColor colorWithRed:(213.0/255) green:(213.0/255) blue:(213.0/255) alpha:1];;
        _viewIconCenterHY.layer.masksToBounds=YES;
        _viewIconCenterHY.layer.cornerRadius=12.5;
        _viewIconCenterHY.layer.shadowColor = [UIColor blackColor].CGColor;
        _viewIconCenterHY.layer.shadowOffset = CGSizeMake(-3, 1);
        _viewIconCenterHY.layer.shadowOpacity = 0.4;
        _viewIconCenterHY.layer.shadowRadius = 2.0;
        _viewIconCenterHY.clipsToBounds = NO;
    }
    return _viewIconCenterHY;
}
//头像
- (UIButton *)iconTouxiangCenterHY
{
    if (!_iconTouxiangCenterHY)
    {
        _iconTouxiangCenterHY=[[UIButton alloc] init];
        [_iconTouxiangCenterHY setBackgroundImage:[UIImage imageNamed:@"toixiang"] forState:UIControlStateNormal];
    }
    return _iconTouxiangCenterHY;
}
//名字
- (UILabel *)nameTextCenterHY
{
    if (!_nameTextCenterHY)
    {
        _nameTextCenterHY=[[UILabel alloc] init];
        _nameTextCenterHY.text=@"后悔的小公主";
        _nameTextCenterHY.textColor=[UIColor colorWithRed:(51.0/255) green:(51.0/255) blue:(51.0/255) alpha:1];
        _nameTextCenterHY.font=[UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _nameTextCenterHY;
}
//等级图标
- (UIImageView *)dengjiTBCenterHY
{
    if (!_dengjiTBCenterHY)
    {
        _dengjiTBCenterHY=[[UIImageView alloc] init];
        _dengjiTBCenterHY.image=[UIImage imageNamed:@"dengji1"];
    }
    return _dengjiTBCenterHY;
}
//等级
- (UILabel *)dengjiTextCenterHY
{
    if (!_dengjiTextCenterHY)
    {
        _dengjiTextCenterHY=[[UILabel alloc] init];
        _dengjiTextCenterHY.text=@"100级";
        _dengjiTextCenterHY.textColor=[UIColor colorWithRed:(153.0/255) green:(153.0/255) blue:(153.0/255) alpha:1];
        _dengjiTextCenterHY.font=[UIFont systemFontOfSize:kWidthScale(10)];
    }
    return _dengjiTextCenterHY;
}
//发表时间图标
- (UIImageView *)iconShijianCenterHY
{
    if (!_iconShijianCenterHY)
    {
        _iconShijianCenterHY=[[UIImageView alloc] init];
        _iconShijianCenterHY.image=[UIImage imageNamed:@"time"];
    }
    return _iconShijianCenterHY;
}
//发表时间
- (UILabel *)shijianTextCenterHY
{
    if (!_shijianTextCenterHY)
    {
        _shijianTextCenterHY=[[UILabel alloc] init];
        _shijianTextCenterHY.text=@"5:20";
        _shijianTextCenterHY.textColor=[UIColor colorWithRed:(153.0/255) green:(153.0/255) blue:(153.0/255) alpha:1];
        _shijianTextCenterHY.font=[UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _shijianTextCenterHY;
}
//浏览图标
- (UIImageView *)iconLiulangCenterHY
{
    if (!_iconLiulangCenterHY)
    {
        _iconLiulangCenterHY=[[UIImageView alloc] init];
        _iconLiulangCenterHY.image=[UIImage imageNamed:@"liulans"];
    }
    return _iconLiulangCenterHY;
}
//浏览人数
- (UILabel *)liulangNumCenterHY
{
    if (!_liulangNumCenterHY)
    {
        _liulangNumCenterHY=[[UILabel alloc] init];
        _liulangNumCenterHY.text=@"1000";
        _liulangNumCenterHY.textColor=[UIColor colorWithRed:(153.0/255) green:(153.0/255) blue:(153.0/255) alpha:1];
        _liulangNumCenterHY.font=[UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _liulangNumCenterHY;
}
//点赞图片
- (UIImageView *)dianzanIconCenterHY
{
    if (!_dianzanIconCenterHY)
    {
        _dianzanIconCenterHY=[[UIImageView alloc] init];
        _dianzanIconCenterHY.image=[UIImage imageNamed:@"zans"];
    }
    return _dianzanIconCenterHY;
}
//点赞数量
- (UILabel *)dianzanNumCenterHY
{
    if (!_dianzanNumCenterHY)
    {
        _dianzanNumCenterHY=[[UILabel alloc] init];
        _dianzanNumCenterHY.text=@"100000";
        _dianzanNumCenterHY.textColor=[UIColor colorWithRed:(153.0/255) green:(153.0/255) blue:(153.0/255) alpha:1];
        _dianzanNumCenterHY.font=[UIFont systemFontOfSize:kWidthScale(12)];
    }
    return _dianzanNumCenterHY;
}
//背景颜色
- (UIView *)jianJieViewCenterHY
{
    if (!_jianJieViewCenterHY)
    {
        _jianJieViewCenterHY = [[UIView alloc] init];
        _jianJieViewCenterHY.layer.shadowColor = [UIColor blackColor].CGColor;
        _jianJieViewCenterHY.layer.shadowOffset = CGSizeMake(0, 1);
        _jianJieViewCenterHY.layer.shadowOpacity = 0.2;
        //        _shadowView.layer.shadowRadius = 6.0;
        //        _shadowView.layer.cornerRadius = 6.0;
        _jianJieViewCenterHY.clipsToBounds = NO;
    }
    return _jianJieViewCenterHY;
}
//简介内容
- (KQlable *)jianjieContextCenterHY
{
    if (!_jianjieContextCenterHY)
    {
        _jianjieContextCenterHY = [[KQlable alloc] init];
        _jianjieContextCenterHY.text = @"风暴简介：个环境可凉快和包教包零零落落零零落落零零落落零零落落零零落落啦啦啦\n";
        _jianjieContextCenterHY.backgroundColor = [UIColor colorWithRed:251.0/255 green:251.0/255 blue:251.0/255 alpha:1];
        _jianjieContextCenterHY.textColor = [UIColor colorWithHexString:@"#999999"];
        _jianjieContextCenterHY.font=[UIFont systemFontOfSize:kWidthScale(11)];
        _jianjieContextCenterHY.layer.cornerRadius = kWidthScale(10);
        _jianjieContextCenterHY.layer.masksToBounds = YES;
        _jianjieContextCenterHY.numberOfLines=0;
        NSDictionary *attrDict1 = @{ NSForegroundColorAttributeName: [UIColor colorWithHexString:@"#666666"] };
        NSString *str = @"风暴简介：";
        _jianjieContextCenterHY.attributedText = [[NSAttributedString alloc] initWithString: str attributes: attrDict1];
        
    }
    return _jianjieContextCenterHY;
}
- (void)drawTextInRect:(CGRect)rect {
    UIEdgeInsets insets = {0, 5, 0, 5};
    [self drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)];
}

//发表图片
- (UIImageView *)fabiaoImageCenterHY
{
    if (!_fabiaoImageCenterHY)
    {
        _fabiaoImageCenterHY=[[UIImageView alloc] init];
        _fabiaoImageCenterHY.image=[UIImage imageNamed:@"banner"];
        _fabiaoImageCenterHY.layer.masksToBounds=YES;
        _fabiaoImageCenterHY.layer.cornerRadius=kWidthScale(10);
    }
    return _fabiaoImageCenterHY;
}
//最佳讨论
- (UILabel *)zuijiaTextCenterHY
{
    if (!_zuijiaTextCenterHY)
    {
        _zuijiaTextCenterHY=[[UILabel alloc] init];
        _zuijiaTextCenterHY.text=@"席位(18/18)";
        _zuijiaTextCenterHY.textColor=[UIColor colorWithHexString:@"#666666"];
        _zuijiaTextCenterHY.font=[UIFont systemFontOfSize:kWidthScale(11)];
    }
    return _zuijiaTextCenterHY;
}

//添加最佳讨论人头像
- (UIButton *)addButCenterHY
{
    if (!_addButCenterHY)
    {
        _addButCenterHY=[[UIButton alloc] init];
        [_addButCenterHY setBackgroundImage:[UIImage imageNamed:@"jias"] forState:UIControlStateNormal];
    }
    return _addButCenterHY;
}
//线条
- (UILabel *)labelLine
{
    if (!_labelLine)
    {
        _labelLine=[[UILabel alloc] init];
        _labelLine.backgroundColor=[UIColor colorWithRed:242.0/255.0 green:242.0/255.0 blue:242.0/255.0 alpha:1];
    }
    return _labelLine;
}
//进入会议
- (UIButton *)enterInto
{
    if (!_enterInto)
    {
        _enterInto=[[UIButton alloc] init];
        [_enterInto setBackgroundImage:[UIImage imageNamed:@"jinruhuiyian"] forState:UIControlStateNormal];
    }
    return _enterInto;
}
//用户发表内容
- (KQlable *)thelabelHY
{
    if (!_thelabelHY)
    {
        _thelabelHY=[[KQlable alloc] init];
        _thelabelHY.font=[UIFont systemFontOfSize:kWidthScale(26/2)];
        _thelabelHY.text=@"为什么要度大学？";
        _thelabelHY.textColor = [UIColor colorWithWhite:0.9 alpha:1];
        _thelabelHY.textAlignment = NSTextAlignmentCenter;
        _thelabelHY.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
//        _thelabelHY.layer.cornerRadius = kWidthScale(5);
//        _thelabelHY.layer.masksToBounds = YES;

        
    }
    return _thelabelHY;
}

@end
